home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataOutputStream;
- import java.io.IOException;
- import symjava.lang.Bignum;
- import symjava.sql.SQLException;
-
- class Bit extends NumberField {
- boolean _bVal;
-
- int getType() {
- return 87;
- }
-
- void readData(ServerObject data) throws SQLException, IOException, ErrorException {
- this._bVal = ((NetData)data).getBool();
- }
-
- void writeData(DataOutputStream os) throws IOException {
- NetData data = new NetData(this._bVal);
- data.write(os);
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : String.valueOf(this._bVal);
- }
-
- public boolean getBoolean() throws SQLException {
- return ((Field)this).isNull() ? false : this._bVal;
- }
-
- public byte getByte() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- return (byte)(this._bVal ? 1 : 0);
- }
- }
-
- public short getShort() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- return (short)(this._bVal ? 1 : 0);
- }
- }
-
- public int getInt() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- return this._bVal ? 1 : 0;
- }
- }
-
- public long getLong() throws SQLException {
- return ((Field)this).isNull() ? 0L : (long)(this._bVal ? 1 : 0);
- }
-
- public float getFloat() throws SQLException {
- return ((Field)this).isNull() ? 0.0F : (float)(this._bVal ? 1 : 0);
- }
-
- public double getDouble() throws SQLException {
- if (((Field)this).isNull()) {
- return (double)0.0F;
- } else {
- return this._bVal ? (double)1.0F : (double)0.0F;
- }
- }
-
- public Bignum getBignum(int scale) throws SQLException {
- return ((Field)this).isNull() ? null : new Bignum(this._bVal ? 1 : 0, scale);
- }
-
- public void setBoolean(boolean x) throws SQLException {
- this._bVal = x;
- super._null = false;
- }
-
- public void setByte(byte x) throws SQLException {
- this._bVal = x != 0;
- super._null = false;
- }
-
- public void setShort(short x) throws SQLException {
- this._bVal = x != 0;
- super._null = false;
- }
-
- public void setInt(int x) throws SQLException {
- this._bVal = x != 0;
- super._null = false;
- }
-
- public void setLong(long x) throws SQLException {
- this._bVal = x != 0L;
- super._null = false;
- }
-
- public void setFloat(float x) throws SQLException {
- this._bVal = x != 0.0F;
- super._null = false;
- }
-
- public void setDouble(double x) throws SQLException {
- this._bVal = x != (double)0.0F;
- super._null = false;
- }
-
- public void setBignum(Bignum x) throws SQLException {
- this._bVal = x.intValue() != 0;
- super._null = false;
- }
-
- public void setString(String x) throws SQLException {
- Integer i = new Integer(x);
- this._bVal = i != 0;
- super._null = false;
- }
-
- public int getSQLType() {
- return -7;
- }
-
- public Object getObject() throws SQLException {
- return new Boolean(this._bVal);
- }
-
- public void setObject(Object obj) throws SQLException {
- this.setBoolean((Boolean)obj);
- }
- }
-